@extends('admin.master')
<script src="/js/admin/index.js"></script>

@section('title', '购买流量价格设置')
	
@section('firstItem')
@parent
				<span>购买流量价格设置</span>
				<input class="a_indexbg" type="hidden" value="index" />
				
@stop
@section('searchList')
@parent
				<div class="seizeBox"></div>
@stop
@section('dataTables')
@parent
			<!-- html布局 -->
			<div class="setEditBox">
				<div style="text-align: center; color: #f00">示例：修改为0.5元每升，表示一元钱可以购买2升流量，请谨慎修改！</div>
				<div style="text-align: center; font-weight:bold;">购买价格：<span>{{ $price }}</span>元/升</div>
				<div class="buttonBox">
					<a class="buttonEdit">编辑</a>
					<a class="buttonYes" style="display: none;">确定</a>
					<a class="buttonNo" style="display: none;">取消</a>
				</div>
			</div>
			<script type="text/javascript">
				window.onload=function(){
					$(".priceConversion").css("backgroundColor","#224247").siblings().css("backgroundColor","#365d62").parent().siblings(".menuList").children().css("backgroundColor","#365d62");
					$(".moreSet").show();
					$(".imgMore").show().siblings().hide();
					//编辑按钮
					$(".buttonEdit").click(function(){
						$(".setEditBox div span").attr("contenteditable","true").css("border","solid 1px #ccc").focus();
						$(this).hide().siblings().show();
					});
					//取消按钮
					$(".buttonNo").click(function(){
						window.location="/admin/more/price";
					});
					//确定按钮
					$(".buttonYes").click(function(){
						var inputNum=$(".setEditBox div span").html().replace(/\b(0+)/gi,"");//去掉数值前的0
						$(".setEditBox div span").html(parseFloat(inputNum).toFixed(1));
						$.ajax({
							url:"/admin/api/more/price",
							type:"post",
							dataType:"json",
							data:{
								price:parseFloat(inputNum).toFixed(1)
							},
							success:function(data){
								if(data.status.errCode==0){		
									window.location="/admin/more/price";
								}else{
									hint(data.status.message);
								}
							}
						})
					});
				}
			</script>
@stop

